package com.jianglin.mapper;

import com.jianglin.entity.HouseHoldInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author jianglin
 * 住户信息的mapper层
 */
@Mapper
public interface HouseHoldInfoMapper {
    @Select({"<script>" ,
            "<bind name=\"pattern\" value=\"'%'+_parameter+'%'\"/>" ,
            "select * from householdinfo" ,
            "<where>" ,
            "   <if test=\"householdName!=null and householdName!=''\">" ,
            "       householdName like #{pattern}" ,
            "   </if>" ,
            "</where>" ,
            "</script>"})
    List<HouseHoldInfo> findAll(String householdName);
    @Insert("insert into householdinfo (householdNo, householdName, tel, location) values (#{householdNo}, #{householdName}, #{tel}, #{location})")
    int saveHouseHoldInfo(HouseHoldInfo houseHoldinfo);
    @Update("update householdinfo set householdNo=#{householdNo},householdName=#{householdName},tel=#{tel},location=#{location} where id=#{id}")
    int update(HouseHoldInfo houseHoldInfo);
    @Delete("delete from householdinfo where id=#{id}")
    int deleteById(int id);
    @Delete({
            "<script>",
            "DELETE FROM householdinfo",
            "WHERE id IN",
            "  <foreach item='id' collection='ids' open='(' separator=',' close=')'>",
            "    #{id}",
            "  </foreach>",
            "</script>"
    })
    int delByIds(@Param("ids") List<Integer> ids);
}
